测试链接：https://leetcode.cn/problems/valid-triangle-number/description/
class Solution {
public:

    int triangleNumber(vector<int>& nums) {
        sort(nums.begin(),nums.end());
        int count = 0;
        int n = nums.size();   
        for(int l = 0, r = n-1; r >= 0; r--)
        {
            int left = 0, right = r-1;
            while(left < right)
            {
                if(nums[left] + nums[right] > nums[r])
                {
                    count += right - left;
                    right--;
                }
                else
                {
                    left++;
                }
            }
        }  
        return count;     
    }
};